﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using BusinessLayer;
using Ocean.OceanFramework.MVVM;
using Ocean.OceanFramework.CommonDialog;
using BusinessEntityObjects;
using System.Collections.ObjectModel;
using Ocean.OceanFramework.WPF.Utility;
using System.Windows.Input;
using WPFLOBMVVM.Model; 

namespace WPFLOBMVVM.ViewModel
{
    public class RecentActivityViewModel : ContainerFormViewModelBase
    {

        #region " Declarations "

        private ICommand _cmdBlogNavigateCommand;
        private List<BlogPost> _objRecentBlogActivity = new List<BlogPost>();

        #endregion

        #region " Properties "

        public override int SaveExecute()
        {
            return 1;
        }

        public override bool IsDirty
        {
            get { return false; }
        }

        public List<BlogPost> RecentBlogActivity
        {
            get { return _objRecentBlogActivity; }

            private set
            {
                _objRecentBlogActivity = value;
                OnPropertyChanged("RecentBlogActivity");
            }
        }

        #endregion

        #region " Command Properties "

        public ICommand BlogNavigateCommand
        {
            get
            {

                if (_cmdBlogNavigateCommand == null)
                {
                    _cmdBlogNavigateCommand = new RelayCommand(BlogNavigateExecute, CanBlogNavigateExecute);
                }

                return _cmdBlogNavigateCommand;
            }
        }

        #endregion

        #region " Constructor "

        public RecentActivityViewModel(List<BlogPost> objRecentBlogActivity)
        {
            this.RecentBlogActivity = objRecentBlogActivity;
            base.ViewModelFriendlyName = "Recent Blog Activity";
        }

        #endregion

        #region " Methods "

        private void BlogNavigateExecute(object param)
        {

            if (CanBlogNavigateExecute(param))
            {

                try
                {
                    Helpers.StartProcessWithFileName(param.ToString());
                }

                catch (Exception ex)
                {
                    ViewModelUIService.ExceptionDialog(ex, 0 );
                }
            }


        }

        private bool CanBlogNavigateExecute(object param)
        {
            return param != null && !string.IsNullOrEmpty(param.ToString());
        }
    }

        #endregion 
}
